import { Scalar as n } from '../../nodes/Scalar.js';
import { stringifyNumber as o } from '../../stringify/stringifyNumber.js';
const f = {
    identify: t => typeof t == 'number',
    default: !0,
    tag: 'tag:yaml.org,2002:float',
    test: /^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/,
    resolve: t =>
      t.slice(-3).toLowerCase() === 'nan'
        ? NaN
        : t[0] === '-'
          ? Number.NEGATIVE_INFINITY
          : Number.POSITIVE_INFINITY,
    stringify: o,
  },
  l = {
    identify: t => typeof t == 'number',
    default: !0,
    tag: 'tag:yaml.org,2002:float',
    format: 'EXP',
    test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
    resolve: t => parseFloat(t),
    stringify(t) {
      const e = Number(t.value);
      return isFinite(e) ? e.toExponential() : o(t);
    },
  },
  N = {
    identify: t => typeof t == 'number',
    default: !0,
    tag: 'tag:yaml.org,2002:float',
    test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
    resolve(t) {
      const e = new n(parseFloat(t)),
        a = t.indexOf('.');
      return (
        a !== -1 &&
          t[t.length - 1] === '0' &&
          (e.minFractionDigits = t.length - a - 1),
        e
      );
    },
    stringify: o,
  };
export { N as float, l as floatExp, f as floatNaN };
